 





var bClick = 1;



function ClickAA(Id)

{

    document.getElementById("BG_"+Id).setAttribute("class", "css_over_p");

    document.getElementById("IMG_"+Id).style.display="block";

  //  document.getElementById("IMG_"+Id).setAttribute("src", "/images/deadd.png");

    document.getElementById("BG_"+Id).setAttribute("class", "css_over_pp");

    bClick = 1;

}

function UnClickAA(Id)

{

    document.getElementById("IMG_"+Id).style.display="none";

    document.getElementById("BG_"+Id).setAttribute("class", "css_out_p");

    document.getElementById("IMG_"+Id).setAttribute("class", "css_over_pp");

    bClick = 0;

}



function CheckActive(Product_Id)

{

    var xmlHttp=GetXmlHttpObject();

        if (xmlHttp==null){

	        alert ("Browser does not support HTTP Request");

	        return;

        }

        //var att = document.getElementById("hiden_att").value;



        var url="/adminfree/pages/Ajax/Normal_Ajax.aspx?Type=checkavtive&vn=no000002&Product_Id="+Product_Id+"&Catch_Id="+Math.random();

       

        xmlHttp.onreadystatechange=function()

        {

	        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

             {		   	

                if(xmlHttp.responseText=="True")

                {

                    if(CHeckPro(Product_Id)==true)

                    {

                        arr.push(Product_Id);

                        ClickAA(Product_Id);

                    }

                }

             } 	

        } 

        xmlHttp.open("GET",url,true)

        xmlHttp.send(null)  

       return;  

}



function OVER_PP(Id)

{

    if(CHeckPro(Id)==true)

    {

        document.getElementById("BG_"+Id).setAttribute("class", "css_over_p");

        document.getElementById("IMG_"+Id).style.display="block";

        document.getElementById("IMG_"+Id).setAttribute("src", "/images/add.png");

        document.getElementById("IMG_"+Id).setAttribute("class", "css_over_pp");

    }

    

}

function OUT_PP(Id)

{

    if(CHeckPro(Id)==true)

    {

        document.getElementById("IMG_"+Id).style.display="none";

        document.getElementById("BG_"+Id).setAttribute("class", "css_out_p");

        document.getElementById("IMG_"+Id).setAttribute("class", "css_over_pp");

    }

    

}



var arr = new Array();

function CHeckPro(Id)

{

    for(i=0;i<arr.length;i++)

    {

        if(arr[i]==Id)

            return false;

    }

    return true;

}

function RemoveArr(Id)

{

    var _arr = new Array();

    for(i=0;i<arr.length;i++)

    {

        if(arr[i]!=Id)

            _arr.push(arr[i]);

    }

    arr = _arr;

}

function AddToCart(Product_Id,Product_Price)

{   

    if(CHeckPro(Product_Id)==true)

    {

        arr.push(Product_Id);

        ClickAA(Product_Id);

    }

    else

    {

        RemoveArr(Product_Id);

        UnClickAA(Product_Id);

    }

   LoadShopCart(Product_Id,1,Product_Price);

   

    

}

function GetXmlHttpObject()

{

    var xmlHttp=null;

    try{

        // Firefox, Opera 8.0+, Safari

        xmlHttp=new XMLHttpRequest();

    }

    catch (e){

        //Internet Explorer

        try{

	        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

        }

        catch (e){

	        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

        }

    }

    return xmlHttp;

}

function LoadShopCart(Product_Id,quantity,Product_Price)

{

        

        var xmlHttp=GetXmlHttpObject();

        if (xmlHttp==null){

	        alert ("Browser does not support HTTP Request");

	        return;

        }

        //var att = document.getElementById("hiden_att").value;



        var url="/adminfree/pages/Ajax/Normal_Ajax.aspx?Type=addcart&vn=no000002&Product_Id="+Product_Id+"&Product_Price="+Product_Price+"&Quantity="+quantity+"&Catch_Id="+Math.random();

       

        xmlHttp.onreadystatechange=function()

        {

	        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

             {		   	

                GetProcess();

             } 	

        } 

        xmlHttp.open("GET",url,true)

        xmlHttp.send(null)  

       return;        

    

}



function Get_Future_Id(Product_Id,Product_Name)

{

        

        var xmlHttp=GetXmlHttpObject();

        if (xmlHttp==null){

	        alert ("Browser does not support HTTP Request");

	        return;

        }

        //var att = document.getElementById("hiden_att").value;



        var url="/adminfree/pages/ajax/Normal_ajax.aspx?Type=getfutureid_by_product_id&Product_Id="+Product_Id+"&Catch_Id="+Math.random();

       

        xmlHttp.onreadystatechange=function()

        {

	        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

	         {		   	

	                var Future_Id = xmlHttp.responseText;

	                if(Future_Id=="-2")

	                {

	                    window.location.replace("/VN/Thong-tin-san-pham/"+Product_Id+"/"+Product_Name+"/");

	                }

	                else

	                    if(Future_Id=="")

	                    {

	                        alert("Đã có lỗi xảy ra, vui lòng thử lại. Xin cám ơn.");

	                        return false;

	                    }

	                    else

	                        Get_NPrice(xmlHttp.responseText,Product_Id);

	                

	         } 	

        } 

        xmlHttp.open("GET",url,true)

        xmlHttp.send(null)  

       return;        

    

}

function Get_NPrice(Future_Id,Product_Id)

{

        

        var xmlHttp=GetXmlHttpObject();

        if (xmlHttp==null){

	        alert ("Browser does not support HTTP Request");

	        return;

        }

        //var att = document.getElementById("hiden_att").value;



        var url="/adminfree/pages/ajax/Normal_ajax.aspx?Type=getprice_by_fid&Future_Id="+Future_Id+"&Catch_Id="+Math.random();

       

        xmlHttp.onreadystatechange=function()

        {

	        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

	         {		   	

	                LoadShopCart(Future_Id,Product_Id,xmlHttp.responseText,1);

	         } 	

        } 

        xmlHttp.open("GET",url,true)

        xmlHttp.send(null)  

       return;        

    

}

    function SubChange()

    {

        var IdSort = document.getElementById("ctl00_ContentPlaceHolder1_drop_sort").value;

        

            window.location.replace("/VN/Danh-sach-san-pham/1/108.109.108/Phim-Mói/1/"+IdSort+"/-1/");

    }

    function SubShow()

    {

        var IdSort = document.getElementById("ctl00_ContentPlaceHolder1_drop_show").value;

        window.location.replace("/VN/Danh-sach-san-pham/1/108.109.108/Phim-Mói/1/az/"+IdSort+"/");

            

    }

   


    

    GetProcess();

    function GetXmlHttpObjectMaster()

    {

        var xmlHttp=null;

        try{

            // Firefox, Opera 8.0+, Safari

            xmlHttp=new XMLHttpRequest();

        }

        catch (e){

            //Internet Explorer

            try{

	            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

            }

            catch (e){

	            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

            }

        }

        return xmlHttp;

    }

    function GetProcess()

    {

            

            var xmlHttp=GetXmlHttpObjectMaster();

            if (xmlHttp==null){

	            alert ("Browser does not support HTTP Request");

	            return;

            }

           



            var url="/adminfree/pages/Ajax/Normal_Ajax.aspx?Type=getprocess&Catch_Id="+Math.random();

           

            xmlHttp.onreadystatechange=function()

            {

	            if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

                 {		   	

                    document.getElementById("TT_Process").innerHTML = xmlHttp.responseText;

                 } 	

            } 

            xmlHttp.open("GET",url,true)

            xmlHttp.send(null)  

           return;        

        

    }


